/*
clear all

use PULSE_weeks_1_72.dta, clear

drop if week < 34

save PULSE_weeks_34_72.dta, replace
*/

use PULSE_weeks_34_72.dta, clear

svyset [pweight=household_weight]
set scheme s1color

**Clean up**
replace private_insurance=. if private_insurance==3
replace public_insurance=. if public_insurance==3

gen has_insurance = .
replace has_insurance =0 if private_insurance==0 | public_insurance==0
replace has_insurance =1 if private_insurance==1 | public_insurance==1

replace disability =1 if disability2 ==1

replace current_rentmortgage=1 if TENURE==1 | TENURE==4

gen female=.
replace female=0 if gender_identity !=2
replace female=1 if gender_identity ==2
replace female=. if gender_identity ==.

gen married=.
replace married=0 if marital_status !=1
replace married=1 if marital_status==1

recode employed (2=0)

gen retired =0
replace retired=1 if unemployed==7

gen male=. 
replace male=0 if female==1
replace male=1 if female==0

gen no_college=.
replace no_college=0 if educ > 4
replace no_college=1 if educ < 5

gen college=.
replace college=0 if educ < 5
replace college=1 if educ > 4

gen nonconforming=.
replace nonconforming=0 if gender_identity==1 | gender_identity==2
replace nonconforming=1 if gender_identity==3 | gender_identity==4

gen children_binary=.
replace children_binary=0 if hh_kids==0
replace children_binary=1 if hh_kids > 0

label define college_label 0 "No College" 1 "College"
label values college college_label

label define child_binary_lab 0 "No" 1 "Yes"
label values children_binary child_binary_lab


drop race
gen race = .
replace race=1 if white==1
replace race=2 if black==1
replace race=3 if hispanic==1
replace race=4 if race==.
label define race_label 1 "White" 2 "Black" 3 "Hispanic" 4 "Other"
label values race race_label

recode gender_identity (4=3)
label define gender_label 1 "Male" 2 "Female" 3 "Nonconforming"
label values gender_identity gender_label

gen government_assistance = 0
replace government_assistance = 1 if received_ui==1 | snap==1 | ctc==1 | rent_assistance==1 | insured_medicaid==1 | insured_medicare==1


*******************************************************************
* Multiple imputation for family income 
*******************************************************************
mi set wide
mi register imputed income
mi impute chained (regress) income = age female married hh_kids employed retired college race gender_identity retired hh_size state disability, add(10) force rseed(1994)
gen income_imp = (_1_income+_2_income+_3_income+_4_income+_5_income+_6_income+_7_income+_8_income+_9_income+_10_income)/10
drop _*

keep energy_bill food_sufficiency current_rent current_mortgage current_rentmortgage has_insurance expense_difficulties male female nonconforming lgbtq white black hispanic race gender_identity college no_college hh_kids children_binary married government_assistance dwelling_type rent income income_imp retired age region hh_size employed disability state week person_weight household_weight metro children_under5 children_5_11 children_12_17 government_assistance public_insurance private_insurance not_straight

save sample_int.dta, replace

clear all
use sample_int.dta, clear

gen id = _n
mi tsset id week
gen bill_afford = .
replace bill_afford=0 if energy_bill==1
replace bill_afford=1 if energy_bill==2 | energy_bill==3 | energy_bill==4
gen food_afford=.
replace food_afford=0 if food_sufficiency==1 | food_sufficiency==2
replace food_afford=1 if food_sufficiency==3 | food_sufficiency==4
gen expense_afford=.
replace expense_afford=0 if expense_difficulties==1
replace expense_afford=1 if expense_difficulties==2 | expense_difficulties==3 | expense_difficulties==4

*1=behind
gen house_afford=.
replace house_afford=0 if current_rentmortgage==1
replace house_afford=1 if current_rentmortgage==0

gen no_insurance=.
replace no_insurance=0 if has_insurance==1
replace no_insurance=1 if has_insurance==0

save sample_int2.dta, replace

use sample_int2.dta, clear
mi svyset [pweight=household_weight]

********************************************************************************************************************************************************************
***Figure 1***
********************************************************************************************************************************************************************
label var week "Week"

sort week
collapse bill_afford food_afford house_afford no_insurance [pweight=household_weight], by(week)

set scheme stsj
line bill_afford food_afford house_afford no_insurance week, ///
    ytitle(Percent of Respondents) ///
    ylabel(0.0 (.05) .20 0.0 "0%" .05 "5%" .1 "10%" .15 "15%" .2 "20%" .25 "25%") ///
    xtick(34(4)66 72) ///
    tlabel(34 "July 2021" 38 "38" 42 "42" 46 "46" 50 "50" 54 "54" 58 "58" 62 "62" 66 "66" 72 "Sept 2024", labsize(vsmall)) ///
    legend(label(1 "Unable to pay energy bill") label(2 "Unable to afford food") label(3 "Behind on rent/mortgage") label(4 "No health insuance") label(5 "Difficulty paying expenses") col(2) size(small) pos(6)) ///
    lcolor(dknavy cranberry forest_green dkorange sand)
gr export Figure_d1.png, replace

********************************************************************************************************************************************************************
***Table 2 and Appendix Table A1***
********************************************************************************************************************************************************************
clear all
use sample_int2.dta, clear

global controls i.female i.nonconforming i.black i.hispanic i.disability college children_binary married government_assistance rent income_imp retired age region hh_size employed
global fe i.state i.week


* Table 2*
reg bill_afford $controls $fe [pweight=household_weight], vce(cluster state)
outreg2 using Table_2.rtf, keep($controls) stats(coef se) alpha(0.01, 0.05, 0.1) dec(3) pdec(3) replace
eststo margin: margins female nonconforming black hispanic disability, atmeans post
est sto a1
reg food_afford $controls $fe [pweight=household_weight], vce(cluster state)
outreg2 using Table_2.rtf, keep($controls) stats(coef se) alpha(0.01, 0.05, 0.1) dec(3) pdec(3) append
eststo margin: margins female nonconforming black hispanic disability, atmeans post
est sto a2
reg house_afford $controls $fe [pweight=household_weight], vce(cluster state)
outreg2 using Table_2.rtf, keep($controls) stats(coef se) alpha(0.01, 0.05, 0.1) dec(3) pdec(3) append
eststo margin: margins female nonconforming black hispanic disability, atmeans post
est sto a3
reg no_insurance $controls $fe [pw=household_weight], vce(cluster state)
outreg2 using Table_2.rtf, keep($controls) stats(coef se) alpha(0.01, 0.05, 0.1) dec(3) pdec(3) append
eststo margin: margins female nonconforming black hispanic disability, atmeans post
est sto a4
esttab a1 a2 a3 a4 using Main_MEs.rtf, se(3) replace

**Appendix A1**
qui reg energy_bill $controls $fe [pw=household_weight], vce(cluster state)
outreg2 using Appendix_A1.rtf, keep($controls) stats(coef se) alpha(0.01, 0.05, 0.1) dec(3) pdec(3) replace
qui reg food_sufficiency $controls $fe [pweight=household_weight], vce(cluster state)
outreg2 using Appendix_A1.rtf, keep($controls) stats(coef se) alpha(0.01, 0.05, 0.1) dec(3) pdec(3) append
qui reg house_afford $controls $fe [pw=household_weight], vce(cluster state)
outreg2 using Appendix_A1.rtf, keep($controls) stats(coef se) alpha(0.01, 0.05, 0.1) dec(3) pdec(3) append
qui reg no_insurance $controls $fe [pw=household_weight], vce(cluster state)
outreg2 using Appendix_A1.rtf, keep($controls) stats(coef se) alpha(0.01, 0.05, 0.1) dec(3) pdec(3) append



********************************************************************************************************************************************************************
***Two way intersections, each hardship, Figure 2A and 2B***
********************************************************************************************************************************************************************
clear all
use sample_int2.dta, clear
set scheme s1mono

*main controls
global controls i.female i.nonconforming i.black i.hispanic i.disability college children_binary married government_assistance rent income retired age region hh_size employed 
global ri_controls college children_binary married government_assistance rent income retired age region hh_size employed
global fe i.state i.week


**Energy bill regressions
reg bill_afford race#gender#disability $ri_controls $fe [pw=household_weight], vce(cluster state)
eststo margin: margins race#gender race#disability if race !=4, atmeans post
est sto m1
marginsplot, noci title("Unable to pay energy bill") tlabel(, labsize(small)) legend(order(1 "Male" 2 "Female" 3 "Nonconforming" 4 "No Disability" 5 "Disability") size(small) col(3)) ylabel(0.00(0.1)0.45) xtitle("") ///
    plot1opts(lcolor(dknavy) mcolor(dknavy) msymbol(O) msize(small)) plot2opts(lcolor(cranberry) mcolor(cranberry) msymbol(O) msize(small)) ///
    plot3opts(lcolor(forest_green) mcolor(forest_green) msymbol(O) msize(small)) plot4opts(lcolor(dkorange) mcolor(dkorange) msymbol(O) msize(small)) ///
    plot5opts(lcolor(sand) mcolor(sand) msymbol(O) msize(small))
gr save tmp1, replace
	
	
*Food sufficiency regressions
qui reg food_afford race#gender#disability $ri_controls $fe [pw=household_weight], vce(cluster state)
eststo margin: margins race#gender race#disability if race !=4, atmeans post
est sto m2
marginsplot, noci title("Unable to afford food") tlabel(, labsize(small)) legend(order(1 "Male" 2 "Female" 3 "Nonconforming" 4 "No Disability" 5 "Disability") size(small) col(3)) ylabel(0.0(0.1)0.45) xtitle("") ///
    plot1opts(lcolor(dknavy) mcolor(dknavy) msymbol(O) msize(small)) plot2opts(lcolor(cranberry) mcolor(cranberry) msymbol(O) msize(small)) ///
    plot3opts(lcolor(forest_green) mcolor(forest_green) msymbol(O) msize(small)) plot4opts(lcolor(dkorange) mcolor(dkorange) msymbol(O) msize(small)) ///
    plot5opts(lcolor(sand) mcolor(sand) msymbol(O) msize(small))
gr save tmp2, replace

*Rent/mortgage regressions
qui reg house_afford race#gender#disability $ri_controls $fe [pw=household_weight], vce(cluster state)
eststo margin: margins race#gender race#disability if race !=4, atmeans post
est sto m3
marginsplot, noci title("Unable to pay rent/mortgage") tlabel(, labsize(small)) legend(order(1 "Male" 2 "Female" 3 "Nonconforming" 4 "No Disability" 5 "Disability") size(small) col(3)) ylabel(0(0.05)0.25) xtitle("") ///
    plot1opts(lcolor(dknavy) mcolor(dknavy) msymbol(O) msize(small)) plot2opts(lcolor(cranberry) mcolor(cranberry) msymbol(O) msize(small)) ///
    plot3opts(lcolor(forest_green) mcolor(forest_green) msymbol(O) msize(small)) plot4opts(lcolor(dkorange) mcolor(dkorange) msymbol(O) msize(small)) ///
    plot5opts(lcolor(sand) mcolor(sand) msymbol(O) msize(small))
gr save tmp3, replace

*Health insurance regressions
qui reg no_insurance race#gender#disability $ri_controls $fe [pw=household_weight], vce(cluster state)
eststo margin: margins race#gender race#disability if race !=4, atmeans post
est sto m4
marginsplot, noci title("No health insurance") tlabel(, labsize(small)) legend(order(1 "Male" 2 "Female" 3 "Nonconforming" 4 "No Disability" 5 "Disability") size(small) col(3)) ylabel(0(0.05)0.25) xtitle("") ///
    plot1opts(lcolor(dknavy) mcolor(dknavy) msymbol(O) msize(small)) plot2opts(lcolor(cranberry) mcolor(cranberry) msymbol(O) msize(small)) ///
    plot3opts(lcolor(forest_green) mcolor(forest_green) msymbol(O) msize(small)) plot4opts(lcolor(dkorange) mcolor(dkorange) msymbol(O) msize(small)) ///
    plot5opts(lcolor(sand) mcolor(sand) msymbol(O) msize(small))
gr save tmp4, replace

grc1leg tmp1.gph tmp2.gph, col(2) ysize(25) xsize(10.0)
gr export Figure_2a.png, replace

grc1leg tmp3.gph tmp4.gph, col(2) ysize(25) xsize(10.0)
gr export Figure_2b.png, replace



********************************************************************************************************************************************************************
***Two way intersections, any hardship, Figure 3 and Appendix Table A3***
********************************************************************************************************************************************************************
clear all
use sample_int2.dta, clear
set scheme s1mono

egen hardship_count=rowtotal(bill_afford food_afford house_afford no_insurance)
gen byte any_missing = missing(bill_afford, food_afford, house_afford, no_insurance)
replace hardship_count = . if any_missing

**any hardship
gen any_hardship=.
replace any_hardship=0 if hardship_count==0 
replace any_hardship=1 if hardship_count > 0 & hardship_count !=.


global ri_controls college children_binary married government_assistance rent income retired age region hh_size employed
global fe i.state i.week

***Any hardship**
qui reg any_hardship race#gender race#disability $ri_controls $fe [pw=household_weight]
eststo margin: margins race#gender if race !=4, atmeans post
est sto m1
marginsplot, noci title("Gender Identity") /*tlabel(, nolabels)*/ tlabel(, labsize(small)) ylabel(0.2(0.1)0.5) legend(off) ytitle("Pr(Any Hardship)") xtitle("Blue=Male, Red=Female, Green=Nonconforming") ///
    plot1opts(lcolor(dknavy) mcolor(dknavy) msymbol(O) msize(small)) plot2opts(lcolor(cranberry) mcolor(cranberry) msymbol(O) msize(small)) ///
    plot3opts(lcolor(forest_green) mcolor(forest_green) msymbol(O) msize(small))
gr save temp1, replace

qui reg any_hardship race#gender race#disability $ri_controls $fe [pw=household_weight]
eststo margin: margins race#disability if race !=4, atmeans post
est sto m2
marginsplot, noci title("Disability") /*tlabel(, nolabels)*/ tlabel(, labsize(small)) ylabel(0.2(0.1)0.5)  legend(off) ytitle("Pr(Any Hardship)") xtitle("Orange=No Disability, Gold=Disability") ///
    plot1opts(lcolor(dkorange) mcolor(dkorange) msymbol(O) msize(small)) plot2opts(lcolor(sand) mcolor(sand) msymbol(O) msize(small))
gr save temp2, replace

graph combine temp1.gph temp2.gph, col(2) ysize(15) xsize(30.0) title("Any Hardship")
gr export Figure_3.png, replace

esttab m1 m2 using Table_A3.rtf, se(3) replace


********************************************************************************************************************************************************************
***Two way intersections, count of hardships, Appendix Figure A1 and Table A2***
********************************************************************************************************************************************************************
clear all
use sample_int2.dta, clear

egen hardship_count=rowtotal(bill_afford food_afford house_afford no_insurance)
gen byte any_missing = missing(bill_afford, food_afford, house_afford, no_insurance)
replace hardship_count = . if any_missing

**any hardship
gen any_hardship=.
replace any_hardship=0 if hardship_count==0 
replace any_hardship=1 if hardship_count > 0 & hardship_count !=.

***Count hardship**
reg hardship_count race#gender race#disability $ri_controls $fe [pw=household_weight]
eststo margin: margins race#gender if race !=4, atmeans post
est sto m4
marginsplot, noci title("Gender Identity") /*tlabel(, nolabels)*/ tlabel(, labsize(small)) ylabel(0.2(0.2)1.0) legend(off) xtitle("Blue=Male, Red=Female, Green=Nonconforming") ///
    plot1opts(lcolor(dknavy) mcolor(dknavy) msymbol(O) msize(small)) plot2opts(lcolor(cranberry) mcolor(cranberry) msymbol(O) msize(small)) ///
    plot3opts(lcolor(forest_green) mcolor(forest_green) msymbol(O) msize(small))
gr save temp4, replace


reg hardship_count race#gender race#disability $ri_controls $fe [pw=household_weight]
eststo margin: margins race#disability if race !=4, atmeans post
est sto m5
marginsplot, noci title("Disability") /*tlabel(, nolabels)*/ tlabel(, labsize(small)) ylabel(0.2(0.2)1.0) legend(off) xtitle("Orange=No Disability, Gold=Disability") ///
    plot1opts(lcolor(dkorange) mcolor(dkorange) msymbol(O) msize(small)) plot2opts(lcolor(sand) mcolor(sand) msymbol(O) msize(small))
gr save temp5, replace

graph combine temp4.gph temp5.gph, col(3) ysize(15) xsize(30.0)  title("Hardship Count")
gr export Figure_A1.png, replace

esttab m4 m5 using Table_A4.rtf, se(3) replace



********************************************************************************************************************************************************************
***MULTIPLE INTERSECTIONS, Figure 4 and Table A5 any hardship, Figure A3 and Table A4 count of hardships***
********************************************************************************************************************************************************************
clear all
use sample_int2.dta, clear

**All intersections
egen hardship_count=rowtotal(bill_afford food_afford house_afford no_insurance)
gen byte any_missing = missing(bill_afford, food_afford, house_afford, no_insurance)
replace hardship_count = . if any_missing

**any hardship
gen any_hardship=.
replace any_hardship=0 if hardship_count==0 
replace any_hardship=1 if hardship_count > 0 & hardship_count !=.

global ri_controls college children_binary married government_assistance rent income retired age region hh_size employed
global fe i.state i.week

lab define disslab 0 "No Disability" 1 "Disability"
label values disability disslab

reg hardship_count race#gender#disability $ri_controls $fe [pw=household_weight]
margins race#gender#disability if race !=4, atmeans post
est sto o
marginsplot, noci title("Count of Hardships") legend(size(vsmall) row(4)) tlabel(, labsize(small)) ylabel(0.2(0.2)1.2) xtitle("") ///
    plot1opts(lcolor(dknavy) mcolor(dknavy) msymbol(O) msize(small)) plot2opts(lcolor(cranberry) mcolor(cranberry) msymbol(O) msize(small)) ///
    plot3opts(lcolor(forest_green) mcolor(forest_green) msymbol(O) msize(small)) plot4opts(lcolor(dkorange) mcolor(dkorange) msymbol(O) msize(small)) ///
    plot5opts(lcolor(sand) mcolor(sand) msymbol(O) msize(small)) plot6opts(lcolor(black) mcolor(black) msymbol(O) msize(small))
gr export FigureA3.png, replace
esttab o using Table A4.rtf, se(3) replace

reg any_hardship race#gender#disability $ri_controls $fe [pw=household_weight]
margins race#gender#disability if race !=4, atmeans post
est sto m
marginsplot, noci title("Any Hardship") legend(size(vsmall) row(4)) tlabel(, labsize(small)) ylabel(0.2(0.1)0.6) xtitle("") ///
    plot1opts(lcolor(dknavy) mcolor(dknavy) msymbol(O) msize(small)) plot2opts(lcolor(cranberry) mcolor(cranberry) msymbol(O) msize(small)) ///
    plot3opts(lcolor(forest_green) mcolor(forest_green) msymbol(O) msize(small)) plot4opts(lcolor(dkorange) mcolor(dkorange) msymbol(O) msize(small)) ///
    plot5opts(lcolor(sand) mcolor(sand) msymbol(O) msize(small)) plot6opts(lcolor(black) mcolor(black) msymbol(O) msize(small))
gr export Figure4.png, replace
esttab m using TableA5.rtf, se(3) replace


********************************************************************************************************************************************************************
***ANY HARDSHIP BY SEASON, Appendix Table A2***
********************************************************************************************************************************************************************
clear all 
use sample_int2.dta, clear

egen hardship_count=rowtotal(bill_afford food_afford house_afford no_insurance)
gen byte any_missing = missing(bill_afford, food_afford, house_afford, no_insurance)
replace hardship_count = . if any_missing

**any hardship
gen any_hardship=.
replace any_hardship=0 if hardship_count==0 
replace any_hardship=1 if hardship_count > 0 & hardship_count !=.


global controls i.female i.nonconforming i.black i.hispanic i.disability college children_binary married government_assistance rent income retired age region hh_size employed 
global fe i.state i.week

gen spring = 1 if week==43 | week==44 | week==45 | week==55 | week==56 | week==57 | week==66 | week==67 | week==68
gen summer = 1 if week ==46 | week==47 | week==48 | week==58 | week==59 | week==60 | week==69 | week==70 | week==71
gen fall = 1 if week==49 | week==50 | week==51 | week==61 | week==62 | week==63 | week==72
gen winter =1 if week==52 | week==53 | week==54 | week==64 | week==65


**OVERALL Any hardship**
qui reg any_hardship $controls $fe [pweight=household_weight], vce(cluster state)
outreg2 using TableA2.rtf, keep($controls) stats(coef se) alpha(0.01, 0.05, 0.1) dec(3) pdec(3) replace

***SPRING Any hardship**
drop if spring==.
qui reg any_hardship $controls $fe [pweight=household_weight], vce(cluster state)
outreg2 using TableA2.rtf, keep($controls) stats(coef se) alpha(0.01, 0.05, 0.1) dec(3) pdec(3) append

*******************
clear all 
use sample_int2.dta, clear

egen hardship_count=rowtotal(bill_afford food_afford house_afford no_insurance)
gen byte any_missing = missing(bill_afford, food_afford, house_afford, no_insurance)
replace hardship_count = . if any_missing

**any hardship
gen any_hardship=.
replace any_hardship=0 if hardship_count==0 
replace any_hardship=1 if hardship_count > 0 & hardship_count !=.

global controls i.female i.nonconforming i.black i.hispanic i.disability college children_binary married government_assistance rent income retired age region hh_size employed 
global fe i.state i.week

gen spring = 1 if week==43 | week==44 | week==45 | week==55 | week==56 | week==57 | week==66 | week==67 | week==68
gen summer = 1 if week ==46 | week==47 | week==48 | week==58 | week==59 | week==60 | week==69 | week==70 | week==71
gen fall = 1 if week==49 | week==50 | week==51 | week==61 | week==62 | week==63 | week==72
gen winter =1 if week==52 | week==53 | week==54 | week==64 | week==65

***SUMMER Any hardship**
drop if summer==.
qui reg any_hardship $controls $fe [pweight=household_weight], vce(cluster state)
outreg2 using TableA2.rtf, keep($controls) stats(coef se) alpha(0.01, 0.05, 0.1) dec(3) pdec(3) append


*******************
clear all 
use sample_int2.dta, clear

egen hardship_count=rowtotal(bill_afford food_afford house_afford no_insurance)
gen byte any_missing = missing(bill_afford, food_afford, house_afford, no_insurance)
replace hardship_count = . if any_missing

**any hardship
gen any_hardship=.
replace any_hardship=0 if hardship_count==0 
replace any_hardship=1 if hardship_count > 0 & hardship_count !=.


global controls i.female i.nonconforming i.black i.hispanic i.disability college children_binary married government_assistance rent income retired age region hh_size employed 
global fe i.state i.week

gen spring = 1 if week==43 | week==44 | week==45 | week==55 | week==56 | week==57 | week==66 | week==67 | week==68
gen summer = 1 if week ==46 | week==47 | week==48 | week==58 | week==59 | week==60 | week==69 | week==70 | week==71
gen fall = 1 if week==49 | week==50 | week==51 | week==61 | week==62 | week==63 | week==72
gen winter =1 if week==52 | week==53 | week==54 | week==64 | week==65


***FALL Any hardship**
drop if fall==.
qui reg any_hardship $controls $fe [pweight=household_weight], vce(cluster state)
outreg2 using TableA2.rtf, keep($controls) stats(coef se) alpha(0.01, 0.05, 0.1) dec(3) pdec(3) append

*******************
clear all 
use sample_int2.dta, clear

egen hardship_count=rowtotal(bill_afford food_afford house_afford no_insurance)
gen byte any_missing = missing(bill_afford, food_afford, house_afford, no_insurance)
replace hardship_count = . if any_missing

**any hardship
gen any_hardship=.
replace any_hardship=0 if hardship_count==0 
replace any_hardship=1 if hardship_count > 0 & hardship_count !=.


global controls i.female i.nonconforming i.black i.hispanic i.disability college children_binary married government_assistance rent income retired age region hh_size employed 
global fe i.state i.week

gen spring = 1 if week==43 | week==44 | week==45 | week==55 | week==56 | week==57 | week==66 | week==67 | week==68
gen summer = 1 if week ==46 | week==47 | week==48 | week==58 | week==59 | week==60 | week==69 | week==70 | week==71
gen fall = 1 if week==49 | week==50 | week==51 | week==61 | week==62 | week==63 | week==72
gen winter =1 if week==52 | week==53 | week==54 | week==64 | week==65


***WINTER any hardship**
drop if winter==.
qui reg any_hardship $controls $fe [pweight=household_weight], vce(cluster state)
outreg2 using TableA2.rtf, keep($controls) stats(coef se) alpha(0.01, 0.05, 0.1) dec(3) pdec(3) append



************************************************************************
*****LOGISTIC REGRESSION FIGURE A2 ******
************************************************************************
clear all
use sample_int2.dta, clear
set scheme s1mono


egen hardship_count=rowtotal(bill_afford food_afford house_afford no_insurance)
gen byte any_missing = missing(bill_afford, food_afford, house_afford, no_insurance)
replace hardship_count = . if any_missing

**any hardship
gen any_hardship=.
replace any_hardship=0 if hardship_count==0 
replace any_hardship=1 if hardship_count > 0 & hardship_count !=.


lab define disslab 0 "No Disability" 1 "Disability"
label values disability disslab

global ri_controls college children_binary married government_assistance rent income retired age region hh_size employed
global fe i.state i.week

qui logit any_hardship race#gender#disability $ri_controls $fe [pw=household_weight]
qui margins race#gender#disability if race!=4, atmeans post
marginsplot, noci title("Any Hardship") legend(size(vsmall) row(4)) tlabel(, labsize(small)) ylabel(0.0(0.1)0.6) xtitle("") ///
    plot1opts(lcolor(dknavy) mcolor(dknavy) msymbol(O) msize(small)) plot2opts(lcolor(cranberry) mcolor(cranberry) msymbol(O) msize(small)) ///
    plot3opts(lcolor(forest_green) mcolor(forest_green) msymbol(O) msize(small)) plot4opts(lcolor(dkorange) mcolor(dkorange) msymbol(O) msize(small)) ///
    plot5opts(lcolor(sand) mcolor(sand) msymbol(O) msize(small)) plot6opts(lcolor(black) mcolor(black) msymbol(O) msize(small)) ytitle("Logit Prediction")
gr export FigureA2.png, replace





**********************************************************************************************************
*****TABLE 4, combined with previous marginal effect estimates from no interact and two way******
**********************************************************************************************************
*bill
qui reg bill_afford race#gender race#disability $ri_controls $fe [pw=household_weight]
margins race#gender if race !=4, atmeans post
qui reg bill_afford race#gender race#disability $ri_controls $fe [pw=household_weight]
margins race#disability if race !=4, atmeans post
qui reg bill_afford race#gender race#disability $ri_controls $fe [pw=household_weight]
margins race#gender#disability if race !=4, atmeans post


*food
qui reg food_afford race#gender race#disability $ri_controls $fe [pw=household_weight]
margins race#gender if race !=4, atmeans post
qui reg food_afford race#gender race#disability $ri_controls $fe [pw=household_weight]
margins race#disability if race !=4, atmeans post
qui reg food_afford race#gender race#disability $ri_controls $fe [pw=household_weight]
margins race#gender#disability if race !=4, atmeans post

*current rent/mortgage
qui reg house_afford race#gender race#disability $ri_controls $fe [pw=household_weight]
margins race#gender if race !=4, atmeans post
qui reg house_afford race#gender race#disability $ri_controls $fe [pw=household_weight]
margin race#disability if race !=4, atmeans post
qui reg house_afford race#gender race#disability $ri_controls $fe [pw=household_weight]
margins race#gender#disability if race !=4, atmeans post

*Health insurance regressions
qui reg no_insurance race#gender race#disability $ri_controls $fe [pw=household_weight]
margins race#gender if race !=4, atmeans post
qui reg no_insurance race#gender race#disability $ri_controls $fe [pw=household_weight]
margins race#disability if race !=4, atmeans post
qui reg no_insurance race#gender race#disability $ri_controls $fe [pw=household_weight]
margins race#gender#disability if race !=4, atmeans post